<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>cocoOS: os_applAPI.h File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">cocoOS
   &#160;<span id="projectnumber">3.0.0</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('os__appl_a_p_i_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#define-members">Defines</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">os_applAPI.h File Reference</div>  </div>
</div>
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="cocoos_8h.html">cocoos.h</a>&quot;</code><br/>
</div><table class="memberdecls">
<tr><td colspan="2"><h2><a name="define-members"></a>
Defines</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>()&#160;&#160;&#160;OS_BEGIN</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>()&#160;&#160;&#160;OS_END</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>(x)&#160;&#160;&#160;OS_WAIT_TICKS(x,0)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#aade8755cf226e97b98eff894310f4257">task_wait_id</a>(id, x)&#160;&#160;&#160;OS_WAIT_TICKS(x,id)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a7d1f6736c118f92f06a5d9218e0ba977">task_suspend</a>(taskproc)&#160;&#160;&#160;OS_SUSPEND_TASK( taskproc )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a6de09b7f20e384d58bbf330c19447a79">task_resume</a>(taskproc)&#160;&#160;&#160;OS_RESUME_TASK( taskproc )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a576b2326d068ab852846ee612c7b954c">event_wait</a>(event)&#160;&#160;&#160;OS_WAIT_SINGLE_EVENT(event,0)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#adf6bffac3935c670ced14cf963fb0427">event_wait_timeout</a>(event, timeout)&#160;&#160;&#160;OS_WAIT_SINGLE_EVENT(event,timeout)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a148bf0f2ab640ccf1cf29229d61defb6">event_wait_multiple</a>(waitAll, args...)&#160;&#160;&#160;OS_WAIT_MULTIPLE_EVENTS( waitAll, args)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a194e9ed0f676ffc46a782754b58a0475">event_signal</a>(event)&#160;&#160;&#160;OS_SIGNAL_EVENT(event)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a90cd2126d49864ddb72738c12a01b34e">event_ISR_signal</a>(event)&#160;&#160;&#160;OS_INT_SIGNAL_EVENT(event)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#ab14d890b777d3b2a9e4c83a3ec15dd31">sem_wait</a>(sem)&#160;&#160;&#160;OS_WAIT_SEM(sem)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#aa5011c236fb03784283e6476e9ae5adb">sem_signal</a>(sem)&#160;&#160;&#160;OS_SIGNAL_SEM(sem)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a017f7852a4fe5b619c58a9adf3d57bd7">msg_post</a>(task, msg)&#160;&#160;&#160;OS_MSG_Q_POST(task, msg, 0, 0)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#abaae70bdc9e52397b8cb61698d850cda">msg_post_in</a>(task, msg, delay)&#160;&#160;&#160;OS_MSG_Q_POST(task, msg, delay, 0)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a1d4ff9caf0714728a46973fe7ef76868">msg_post_every</a>(task, msg, period)&#160;&#160;&#160;OS_MSG_Q_POST(task, msg, period, period)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#ac09ba62464c1027ee133b7a6878bfa83">msg_receive</a>(task, pMsg)&#160;&#160;&#160;OS_MSG_Q_RECEIVE( task, pMsg )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get</a>(task)&#160;&#160;&#160;OS_MSG_Q_GET( task )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give</a>(task)&#160;&#160;&#160;OS_MSG_Q_GIVE( task )</td></tr>
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a6cc2e63d83267ff5059bf0a76b302a09">os_init</a> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a19c7111cf2121a69331d99dabe3e9df0">os_start</a> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a1d7bc0554f6b515785211dd2c3f2d3d9">os_tick</a> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#ac48c31882821ef8c2acef85235ee3d13">os_sub_tick</a> (uint8_t id)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a2025fabb507973af46a65be92eca1dd8">os_sub_nTick</a> (uint8_t id, uint16_t nTicks)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a> (taskproctype taskproc, uint8_t prio, Msg_t *msgPool, uint8_t poolSize, uint16_t msgSize)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">TaskState_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a5587eb98c16ed4dd2adaa8ae2f3bb1e1">task_state_get</a> (taskproctype taskproc)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#ab9e114be01c136878fc271be2a9c45cf">task_id_get</a> (taskproctype taskproc)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a36df952f331631590dc3a982e0e8a2d4">task_kill</a> (taskproctype taskproc)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Sem_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#aaecd95706696b8ff18d5ef74d139d750">sem_bin_create</a> (uint8_t initial)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Sem_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a9cfb5b3cc72fdaed17009a0cae7fd725">sem_counting_create</a> (uint8_t max, uint8_t initial)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Evt_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a> (void)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#ae28468ad6bb58df9d34ebd5bd3daa548">event_signaling_taskId_get</a> (Evt_t ev)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="os__appl_a_p_i_8h.html#a6723f9f2646d57c8a5e9bbd7dbc5279c">os_cbkSleep</a> (void)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>cocoOS API header file </p>
</div><hr/><h2>Define Documentation</h2>
<a class="anchor" id="a90cd2126d49864ddb72738c12a01b34e"></a><!-- doxytag: member="os_applAPI.h::event_ISR_signal" ref="a90cd2126d49864ddb72738c12a01b34e" args="(event)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#a90cd2126d49864ddb72738c12a01b34e">event_ISR_signal</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">event</td><td>)</td>
          <td>&#160;&#160;&#160;OS_INT_SIGNAL_EVENT(event)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for signalling an event from an ISR</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">event,:</td><td>the event to be signalled</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment">Evt_t evRxChar;
main() {
 ...
 evRxChar = <a class="code" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a>();
 ...
}

ISR (SIG_UART_RECV) {   
    rx.data[ rx.head ] = UDR;
    <a class="code" href="os__appl_a_p_i_8h.html#a90cd2126d49864ddb72738c12a01b34e">event_ISR_signal</a>( evRxChar );
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="a194e9ed0f676ffc46a782754b58a0475"></a><!-- doxytag: member="os_applAPI.h::event_signal" ref="a194e9ed0f676ffc46a782754b58a0475" args="(event)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#a194e9ed0f676ffc46a782754b58a0475">event_signal</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">event</td><td>)</td>
          <td>&#160;&#160;&#160;OS_SIGNAL_EVENT(event)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for signalling an event.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">event,:</td><td>the event to be signalled</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment">Evt_t myEvent;
main() {
 ...
 myEvent = <a class="code" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a>();
 ...
}

<span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#a194e9ed0f676ffc46a782754b58a0475">event_signal</a>( myEvent );
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="a576b2326d068ab852846ee612c7b954c"></a><!-- doxytag: member="os_applAPI.h::event_wait" ref="a576b2326d068ab852846ee612c7b954c" args="(event)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#a576b2326d068ab852846ee612c7b954c">event_wait</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">event</td><td>)</td>
          <td>&#160;&#160;&#160;OS_WAIT_SINGLE_EVENT(event,0)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for wait for a single event.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">event,:</td><td>the event to wait for</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment">Evt_t myEvent;
main() {
 ...
 myEvent = <a class="code" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a>();
 ...
}

<span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#a576b2326d068ab852846ee612c7b954c">event_wait</a>( myEvent );
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="a148bf0f2ab640ccf1cf29229d61defb6"></a><!-- doxytag: member="os_applAPI.h::event_wait_multiple" ref="a148bf0f2ab640ccf1cf29229d61defb6" args="(waitAll, args...)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#a148bf0f2ab640ccf1cf29229d61defb6">event_wait_multiple</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">waitAll, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">args...&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;OS_WAIT_MULTIPLE_EVENTS( waitAll, args)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for wait for multiple events.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">waitAll</td><td>1 if wait for all, 0 if wait for any event </td></tr>
    <tr><td class="paramname">args</td><td>list of Evt_t type events</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment">Evt_t myEvent1;
Evt_t myEvent2;
Evt_t myEvent3;
main() {
 ...
 myEvent1 = <a class="code" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a>();
 myEvent2 = <a class="code" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a>();
 myEvent3 = <a class="code" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a>();
 ...
}

<span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#a148bf0f2ab640ccf1cf29229d61defb6">event_wait_multiple</a>(1, myEvent1, myEvent2, myEvent3);
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="adf6bffac3935c670ced14cf963fb0427"></a><!-- doxytag: member="os_applAPI.h::event_wait_timeout" ref="adf6bffac3935c670ced14cf963fb0427" args="(event, timeout)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#adf6bffac3935c670ced14cf963fb0427">event_wait_timeout</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">event, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">timeout&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;OS_WAIT_SINGLE_EVENT(event,timeout)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for wait for a single event to be signaled or a timeout to occur.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">event,:</td><td>the event to wait for </td></tr>
    <tr><td class="paramname">timeout,:</td><td>maximum wait time in main clock ticks, 16bit value. If timeout = 0, no timeout will be used, and the task will wait forever until the event is signaled.</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment">Evt_t myEvent;
main() {
 ...
 myEvent = <a class="code" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a>();
 ...
}

<span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#adf6bffac3935c670ced14cf963fb0427">event_wait_timeout</a>( myEvent, 100 );
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="a017f7852a4fe5b619c58a9adf3d57bd7"></a><!-- doxytag: member="os_applAPI.h::msg_post" ref="a017f7852a4fe5b619c58a9adf3d57bd7" args="(task, msg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#a017f7852a4fe5b619c58a9adf3d57bd7">msg_post</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">task, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">msg&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;OS_MSG_Q_POST(task, msg, 0, 0)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Posts a message to the message queue of a task.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>task procedure of the task that will receive the message </td></tr>
    <tr><td class="paramname">msg</td><td>the message to post </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None </dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd>Before posting a message, the queue semaphore should be aquired with a call to <a class="el" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get()</a>. When the message has been posted, the semaphore should be released with <a class="el" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give()</a>. If the message queue is full, the task will release the semaphore and wait for the queue change event to be signaled by another task. When the event is signaled, the task will again aquire the semaphore and try to post the message.<br/>
 <b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">typedef</span> <span class="keyword">struct </span>{
    Msg_t super;
    uint8_t led;
} LedMsg_t;

 
<span class="keyword">static</span> LedMsg_t msgpool_1[ 16 ];


<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)
{
    ...
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( task1, 1, NULL, 0, 0 );
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( task2, 2, msgpool_1, 16, <span class="keyword">sizeof</span>(LedMsg_t) );
    ...
    <a class="code" href="os__appl_a_p_i_8h.html#a19c7111cf2121a69331d99dabe3e9df0">os_start</a>();
    <span class="keywordflow">return</span> 0;
}


<span class="keyword">static</span> <span class="keywordtype">void</span> task1(<span class="keywordtype">void</span>) {
    <span class="keyword">static</span> LedMsg_t ledMsg;

    ledMsg.super.signal = LED_SIG;
    ledMsg.led = 5;
    
    <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();
    
    <span class="keywordflow">for</span> (;;) {
        
        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 3000 );
        
        <a class="code" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get</a>( task2 );

        <a class="code" href="os__appl_a_p_i_8h.html#a017f7852a4fe5b619c58a9adf3d57bd7">msg_post</a>( task2, ledMsg );

        <a class="code" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give</a>( task2 );  
    }

    <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();

}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="a1d4ff9caf0714728a46973fe7ef76868"></a><!-- doxytag: member="os_applAPI.h::msg_post_every" ref="a1d4ff9caf0714728a46973fe7ef76868" args="(task, msg, period)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#a1d4ff9caf0714728a46973fe7ef76868">msg_post_every</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">task, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">msg, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">period&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;OS_MSG_Q_POST(task, msg, period, period)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Posts a periodic message to the message queue of a task. The message will be delivered to the receiver task each time the timer expires. The period is related to the master clock.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>task procedure of the task that will receive the message </td></tr>
    <tr><td class="paramname">msg</td><td>the message to post </td></tr>
    <tr><td class="paramname">period</td><td>period time in master clock ticks </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None </dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd>Before posting a message, the queue semaphore should be aquired with a call to <a class="el" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get()</a>. When the message has been posted, the semaphore should be released with <a class="el" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give()</a>. If the message queue is full, the task will release the semaphore and wait for the queue change event to be signaled by another task. When the event is signaled, the task will again aquire the semaphore and try to post the message.<br/>
 <b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">typedef</span> <span class="keyword">struct </span>{
    Msg_t super;
    uint8_t led;
} LedMsg_t;

 
<span class="keyword">static</span> LedMsg_t msgpool_1[ 16 ];


<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)
{
    ...
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( task1, 1, NULL, 0, 0 );
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( task2, 2, msgpool_1, 16, <span class="keyword">sizeof</span>(LedMsg_t) );
    ...
    <a class="code" href="os__appl_a_p_i_8h.html#a19c7111cf2121a69331d99dabe3e9df0">os_start</a>();
    <span class="keywordflow">return</span> 0;
}


<span class="keyword">static</span> <span class="keywordtype">void</span> task1(<span class="keywordtype">void</span>) {
    <span class="keyword">static</span> LedMsg_t ledMsg;

    ledMsg.super.signal = LED_SIG;
    ledMsg.led = 5;
    
    <a class="code" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get</a>( task2 );

    <a class="code" href="os__appl_a_p_i_8h.html#a1d4ff9caf0714728a46973fe7ef76868">msg_post_every</a>( task2, ledMsg, 100 );

    <a class="code" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give</a>( task2 );
  
    <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();
    
    <span class="keywordflow">for</span> (;;) {
        ...
        ...
        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 3000 );
    }

    <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();

}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="abaae70bdc9e52397b8cb61698d850cda"></a><!-- doxytag: member="os_applAPI.h::msg_post_in" ref="abaae70bdc9e52397b8cb61698d850cda" args="(task, msg, delay)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#abaae70bdc9e52397b8cb61698d850cda">msg_post_in</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">task, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">msg, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">delay&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;OS_MSG_Q_POST(task, msg, delay, 0)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Posts a message to the message queue of a task. The message will be received by the receiver task when the delay has expired. The delay is related to the master clock.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>task procedure of the task that will receive the message </td></tr>
    <tr><td class="paramname">msg</td><td>the message to post </td></tr>
    <tr><td class="paramname">delay</td><td>post delay time in master clock ticks </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None </dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd>Before posting a message, the queue semaphore should be aquired with a call to <a class="el" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get()</a>. When the message has been posted, the semaphore should be released with <a class="el" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give()</a>. If the message queue is full, the task will release the semaphore and wait for the queue change event to be signaled by another task. When the event is signaled, the task will again aquire the semaphore and try to post the message.<br/>
 <b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">typedef</span> <span class="keyword">struct </span>{
    Msg_t super;
    uint8_t led;
} LedMsg_t;

 
<span class="keyword">static</span> LedMsg_t msgpool_1[ 16 ];


<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)
{
    ...
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( task1, 1, NULL, 0, 0 );
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( task2, 2, msgpool_1, 16, <span class="keyword">sizeof</span>(LedMsg_t) );
    ...
    <a class="code" href="os__appl_a_p_i_8h.html#a19c7111cf2121a69331d99dabe3e9df0">os_start</a>();
    <span class="keywordflow">return</span> 0;
}


<span class="keyword">static</span> <span class="keywordtype">void</span> task1(<span class="keywordtype">void</span>) {
    <span class="keyword">static</span> LedMsg_t ledMsg;

    ledMsg.super.signal = LED_SIG;
    ledMsg.led = 5;
    
    <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();
    
    <span class="keywordflow">for</span> (;;) {
        
        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 3000 );
        
        <a class="code" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get</a>( task2 );

        <a class="code" href="os__appl_a_p_i_8h.html#abaae70bdc9e52397b8cb61698d850cda">msg_post_in</a>( task2, ledMsg, 100 );

        <a class="code" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give</a>( task2 );  
    }

    <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();

}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="ae66288422355db64c18c53676e53eddb"></a><!-- doxytag: member="os_applAPI.h::msg_q_get" ref="ae66288422355db64c18c53676e53eddb" args="(task)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">task</td><td>)</td>
          <td>&#160;&#160;&#160;OS_MSG_Q_GET( task )</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for aquiring a message queue.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>Task procedure associated with the message queue</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> Should be called before any access to a message queue. See <a class="el" href="os__appl_a_p_i_8h.html#a017f7852a4fe5b619c58a9adf3d57bd7">msg_post()</a> example <br/>
 </dd></dl>

</div>
</div>
<a class="anchor" id="adc67691f29549315143cc60ff43e2306"></a><!-- doxytag: member="os_applAPI.h::msg_q_give" ref="adc67691f29549315143cc60ff43e2306" args="(task)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">task</td><td>)</td>
          <td>&#160;&#160;&#160;OS_MSG_Q_GIVE( task )</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for releasing a message queue.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>Task procedure associated with the message queue</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> Should be called after access to a message queue. See <a class="el" href="os__appl_a_p_i_8h.html#a017f7852a4fe5b619c58a9adf3d57bd7">msg_post()</a> example <br/>
 </dd></dl>

</div>
</div>
<a class="anchor" id="ac09ba62464c1027ee133b7a6878bfa83"></a><!-- doxytag: member="os_applAPI.h::msg_receive" ref="ac09ba62464c1027ee133b7a6878bfa83" args="(task, pMsg)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#ac09ba62464c1027ee133b7a6878bfa83">msg_receive</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">task, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">pMsg&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;OS_MSG_Q_RECEIVE( task, pMsg )</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Receives a message from the queue</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">task</td><td>task procedure of the current task </td></tr>
    <tr><td class="paramname">pMsg</td><td>pointer to a message that will receive a message from the queue</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None </dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd>Before receiving a message, the queue semaphore should be aquired with a call to <a class="el" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get()</a>. When the message has been received, the semaphore should be released with <a class="el" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give()</a>. If the message queue is empty, the task will release the semaphore and wait for the queue change event to be signaled by another task. When the event is signaled, the task will again aquire the semaphore and try to receive a message.<br/>
 <b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">typedef</span> <span class="keyword">struct </span>{
    Msg_t super;
    uint8_t led;
} LedMsg_t;

 
<span class="keyword">static</span> LedMsg_t msgpool_1[ 16 ];


<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>)
{
    ...
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( task1, 1, NULL, 0 );
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( task2, 2, msgpool_1, 16, <span class="keyword">sizeof</span>(LedMsg_t) );
    ...
    <a class="code" href="os__appl_a_p_i_8h.html#a19c7111cf2121a69331d99dabe3e9df0">os_start</a>();
    <span class="keywordflow">return</span> 0;
}


<span class="keyword">static</span> <span class="keywordtype">void</span> task2(<span class="keywordtype">void</span>) {
    <span class="keyword">static</span> LedMsg_t msg;
    uint8_t led;
    <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();
    
    <span class="keywordflow">for</span> (;;) {
        
        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 3000 );
        
        <a class="code" href="os__appl_a_p_i_8h.html#ae66288422355db64c18c53676e53eddb">msg_q_get</a>( task2 );

        <a class="code" href="os__appl_a_p_i_8h.html#ac09ba62464c1027ee133b7a6878bfa83">msg_receive</a>( task2, &amp;msg );

        <a class="code" href="os__appl_a_p_i_8h.html#adc67691f29549315143cc60ff43e2306">msg_q_give</a>( task2 );

        <span class="keywordflow">if</span> ( msg.super.signal == LED_SIG ) {
            led = msg.led;
            LED_TOGGLE( led );
        } 
    }

    <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();

}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="aa5011c236fb03784283e6476e9ae5adb"></a><!-- doxytag: member="os_applAPI.h::sem_signal" ref="aa5011c236fb03784283e6476e9ae5adb" args="(sem)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#aa5011c236fb03784283e6476e9ae5adb">sem_signal</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">sem</td><td>)</td>
          <td>&#160;&#160;&#160;OS_SIGNAL_SEM(sem)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for releasing a semaphore.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Semaphore.</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment">Sem_t mySem;
main() {
 ...
 mySem = sem_create( 0 );
 ...
}

<span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#aa5011c236fb03784283e6476e9ae5adb">sem_signal</a>( mySem );
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="ab14d890b777d3b2a9e4c83a3ec15dd31"></a><!-- doxytag: member="os_applAPI.h::sem_wait" ref="ab14d890b777d3b2a9e4c83a3ec15dd31" args="(sem)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#ab14d890b777d3b2a9e4c83a3ec15dd31">sem_wait</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">sem</td><td>)</td>
          <td>&#160;&#160;&#160;OS_WAIT_SEM(sem)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for aquiring a semaphore.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">sem</td><td>Semaphore.</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment">Sem_t mySem;
main() {
 ...
 mySem = sem_create( 0 );
 ...
}

<span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#ab14d890b777d3b2a9e4c83a3ec15dd31">sem_wait</a>( mySem );
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="a7912af19af4a033fd9caf27879614945"></a><!-- doxytag: member="os_applAPI.h::task_close" ref="a7912af19af4a033fd9caf27879614945" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a></td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td>&#160;&#160;&#160;OS_END</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for definition of task end.</p>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> Should be placed at the end of the task procedure <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <span class="keyword">static</span> uint8_t i;
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 10 );
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="ac19d6a48c1cb673360ae220aaf2a9d53"></a><!-- doxytag: member="os_applAPI.h::task_open" ref="ac19d6a48c1cb673360ae220aaf2a9d53" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a></td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td>&#160;&#160;&#160;OS_BEGIN</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for definition of task beginning.</p>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> Should be placed at the beginning of the task procedure <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <span class="keyword">static</span> uint8_t i;
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 10 );
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="a6de09b7f20e384d58bbf330c19447a79"></a><!-- doxytag: member="os_applAPI.h::task_resume" ref="a6de09b7f20e384d58bbf330c19447a79" args="(taskproc)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#a6de09b7f20e384d58bbf330c19447a79">task_resume</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">taskproc</td><td>)</td>
          <td>&#160;&#160;&#160;OS_RESUME_TASK( taskproc )</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for resuming a task</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">taskproc</td><td>Task procedure of the task to resume</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd>The macro has no effect if the task is not in the SUSPENDED state <br/>
 If the task was waiting for a semaphore when it was suspended, the task will be reset and <br/>
 execution will restart from the task procedure top.<br/>
 <b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">static</span> <span class="keywordtype">void</span> led_task(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  <span class="keywordflow">for</span>(;;) {
        led_toggle();
        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 100 );
  }
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}


<span class="keyword">static</span> <span class="keywordtype">void</span> button_task(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();
 <span class="keywordflow">for</span> (;;) {
     <span class="keywordflow">if</span> ( button_1_Pressed ) {
       <a class="code" href="os__appl_a_p_i_8h.html#a7d1f6736c118f92f06a5d9218e0ba977">task_suspend</a>( led_task );
     }
     <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( button_2_Pressed ){
       <a class="code" href="os__appl_a_p_i_8h.html#a6de09b7f20e384d58bbf330c19447a79">task_resume</a>( led_task );
     }
 }
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}


<span class="keywordtype">int</span> main( <span class="keywordtype">void</span> ) {
        ...
        <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( led_task, 1, msgPool, POOL_SIZE, <span class="keyword">sizeof</span>(Msg_t) );
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( button_task, 2, NULL, 0, 0 );
        ...
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="a7d1f6736c118f92f06a5d9218e0ba977"></a><!-- doxytag: member="os_applAPI.h::task_suspend" ref="a7d1f6736c118f92f06a5d9218e0ba977" args="(taskproc)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#a7d1f6736c118f92f06a5d9218e0ba977">task_suspend</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">taskproc</td><td>)</td>
          <td>&#160;&#160;&#160;OS_SUSPEND_TASK( taskproc )</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for suspending a task</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">taskproc</td><td>Task procedure of the task to suspend</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd>If the task to suspend is the same as the current running task, the task is immediately suspended and other tasks are scheduled to execute. If the task to suspend is another than the current task, that task is immediately put in suspended state, and the current task continues to execute. <br/>
 <b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">static</span> Msg_t msgPool[ POOL_SIZE ];

<span class="keyword">static</span> <span class="keywordtype">void</span> led_task(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  <span class="keywordflow">for</span>(;;) {
        led_toggle();
        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 100 );
  }
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}


<span class="keyword">static</span> <span class="keywordtype">void</span> button_task(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();
 <span class="keywordflow">for</span> (;;) {
    <span class="keywordflow">if</span> ( buttonPressed ) {
        <a class="code" href="os__appl_a_p_i_8h.html#a7d1f6736c118f92f06a5d9218e0ba977">task_suspend</a>( led_task );
    }
    <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>(10);
 }
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}


<span class="keywordtype">int</span> main( <span class="keywordtype">void</span> ) {
    ...
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( led_task, 1, msgPool, POOL_SIZE, <span class="keyword">sizeof</span>(Msg_t) );
    <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( button_task, 2, NULL, 0, 0 );
        ...
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="ad8232a672a6d4f3a4532bea410a0b1ef"></a><!-- doxytag: member="os_applAPI.h::task_wait" ref="ad8232a672a6d4f3a4532bea410a0b1ef" args="(x)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">x</td><td>)</td>
          <td>&#160;&#160;&#160;OS_WAIT_TICKS(x,0)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for suspending a task a specified amount of ticks of the master clock. When the wait time has expired, the task is ready to execute again and will continue at the next statement when the task is scheduled to run.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">x</td><td>Number of master clock ticks to wait.</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 10 );
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<a class="anchor" id="aade8755cf226e97b98eff894310f4257"></a><!-- doxytag: member="os_applAPI.h::task_wait_id" ref="aade8755cf226e97b98eff894310f4257" args="(id, x)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define <a class="el" href="os__appl_a_p_i_8h.html#aade8755cf226e97b98eff894310f4257">task_wait_id</a></td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">id, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">x&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;OS_WAIT_TICKS(x,id)</td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Macro for suspending a task a specified amount of ticks of a sub clock. When the wait time has expired, the task is ready to execute again and will continue at the next statement when the task is scheduled to run.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">id</td><td>Sub clock id. Valid range 1-255.</td></tr>
    <tr><td class="paramname">x</td><td>Number of sub clock ticks to wait, 16 bit value.</td></tr>
  </table>
  </dd>
</dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 <div class="fragment"><pre class="fragment"><span class="keyword">static</span> <span class="keywordtype">void</span> myTask(<span class="keywordtype">void</span>) {
 <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();   
  ...
  <a class="code" href="os__appl_a_p_i_8h.html#aade8755cf226e97b98eff894310f4257">task_wait_id</a>( 2, 10 );
  ...
 <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}
</pre></div> </dd></dl>

</div>
</div>
<hr/><h2>Function Documentation</h2>
<a class="anchor" id="a04ba027b0848884aa6a2f5a346444be3"></a><!-- doxytag: member="os_applAPI.h::event_create" ref="a04ba027b0848884aa6a2f5a346444be3" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Evt_t <a class="el" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a> </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Creates an event.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>Returns an event.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 An event is created by declaring a variable of type Evt_t and then assigning the <a class="el" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create()</a> return value to that variable.</dd></dl>
<div class="fragment"><pre class="fragment">       Evt_t myEvent;
       myEvent = <a class="code" href="os__appl_a_p_i_8h.html#a04ba027b0848884aa6a2f5a346444be3">event_create</a>();
</pre></div> 
</div>
</div>
<a class="anchor" id="ae28468ad6bb58df9d34ebd5bd3daa548"></a><!-- doxytag: member="os_applAPI.h::event_signaling_taskId_get" ref="ae28468ad6bb58df9d34ebd5bd3daa548" args="(Evt_t ev)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t <a class="el" href="os__appl_a_p_i_8h.html#ae28468ad6bb58df9d34ebd5bd3daa548">event_signaling_taskId_get</a> </td>
          <td>(</td>
          <td class="paramtype">Evt_t&#160;</td>
          <td class="paramname"><em>ev</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Gets the Task Id of the task that signaled the event.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">ev</td><td>event</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Id of task that signaled the event.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 A task can make a call to this function when it has resumed execution after waiting for an event to find out which other task signaled the event.</dd></dl>
<div class="fragment"><pre class="fragment">       <a class="code" href="os__appl_a_p_i_8h.html#a576b2326d068ab852846ee612c7b954c">event_wait</a>(event);
       signalingTask = <a class="code" href="os__appl_a_p_i_8h.html#ae28468ad6bb58df9d34ebd5bd3daa548">event_signaling_taskId_get</a>(event);
       <span class="keywordflow">if</span> ( signalingTask == Task2_id ) {
         ...
       }
</pre></div> 
</div>
</div>
<a class="anchor" id="a6723f9f2646d57c8a5e9bbd7dbc5279c"></a><!-- doxytag: member="os_applAPI.h::os_cbkSleep" ref="a6723f9f2646d57c8a5e9bbd7dbc5279c" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="os__appl_a_p_i_8h.html#a6723f9f2646d57c8a5e9bbd7dbc5279c">os_cbkSleep</a> </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Callback called by the os kernel when all tasks are in waiting state. Here you can put the MCU to low power mode. Remember to keep the clock running so we can wake up from sleep. </p>

</div>
</div>
<a class="anchor" id="a6cc2e63d83267ff5059bf0a76b302a09"></a><!-- doxytag: member="os_applAPI.h::os_init" ref="a6cc2e63d83267ff5059bf0a76b302a09" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="os__appl_a_p_i_8h.html#a6cc2e63d83267ff5059bf0a76b302a09">os_init</a> </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Initializes the scheduler.</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 Should be called early in system setup, before starting the task execution</dd></dl>
<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>) {
        system_init();
        <a class="code" href="os__appl_a_p_i_8h.html#a6cc2e63d83267ff5059bf0a76b302a09">os_init</a>();
        ...
}
</pre></div> 
</div>
</div>
<a class="anchor" id="a19c7111cf2121a69331d99dabe3e9df0"></a><!-- doxytag: member="os_applAPI.h::os_start" ref="a19c7111cf2121a69331d99dabe3e9df0" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="os__appl_a_p_i_8h.html#a19c7111cf2121a69331d99dabe3e9df0">os_start</a> </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Starts the task scheduling</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 Should be the last line of main.</dd></dl>
<div class="fragment"><pre class="fragment"><span class="keywordtype">int</span> main(<span class="keywordtype">void</span>) {
        system_init();
        <a class="code" href="os__appl_a_p_i_8h.html#a6cc2e63d83267ff5059bf0a76b302a09">os_init</a>();
        <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( myTaskProc, 1, NULL, 0, 0 );
        ...
        <a class="code" href="os__appl_a_p_i_8h.html#a19c7111cf2121a69331d99dabe3e9df0">os_start</a>();
        <span class="keywordflow">return</span> 0;
}
</pre></div> 
</div>
</div>
<a class="anchor" id="a2025fabb507973af46a65be92eca1dd8"></a><!-- doxytag: member="os_applAPI.h::os_sub_nTick" ref="a2025fabb507973af46a65be92eca1dd8" args="(uint8_t id, uint16_t nTicks)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="os__appl_a_p_i_8h.html#a2025fabb507973af46a65be92eca1dd8">os_sub_nTick</a> </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>nTicks</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Tick function driving the sub clocks. Increments the tick count with nTicks.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">id</td><td>sub clock id, allowed range 1-255. </td></tr>
    <tr><td class="paramname">nTicks</td><td>increment size, 16 bit value.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 Could be called at any desired rate to trigger timeouts. <br/>
 Called from a task or from an interrupt ISR.</dd></dl>
<div class="fragment"><pre class="fragment">ISR(SIG_OVERFLOW0) {
        ...
    <a class="code" href="os__appl_a_p_i_8h.html#a2025fabb507973af46a65be92eca1dd8">os_sub_nTick</a>( 2, 10 );      
}
</pre></div> 
</div>
</div>
<a class="anchor" id="ac48c31882821ef8c2acef85235ee3d13"></a><!-- doxytag: member="os_applAPI.h::os_sub_tick" ref="ac48c31882821ef8c2acef85235ee3d13" args="(uint8_t id)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="os__appl_a_p_i_8h.html#ac48c31882821ef8c2acef85235ee3d13">os_sub_tick</a> </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>id</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Tick function driving the sub clocks</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">id</td><td>sub clock id, allowed range 1-255</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 Could be called at any desired rate to trigger timeouts. <br/>
 Called from a task or from an interrupt ISR.</dd></dl>
<div class="fragment"><pre class="fragment">ISR(SIG_OVERFLOW0) {
        ...
    <a class="code" href="os__appl_a_p_i_8h.html#ac48c31882821ef8c2acef85235ee3d13">os_sub_tick</a>(2);     
}
</pre></div> 
</div>
</div>
<a class="anchor" id="a1d7bc0554f6b515785211dd2c3f2d3d9"></a><!-- doxytag: member="os_applAPI.h::os_tick" ref="a1d7bc0554f6b515785211dd2c3f2d3d9" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="os__appl_a_p_i_8h.html#a1d7bc0554f6b515785211dd2c3f2d3d9">os_tick</a> </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Tick function driving the kernel</p>
<dl class="return"><dt><b>Returns:</b></dt><dd>None.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 Should be called periodically. Preferably from the clock tick ISR.</dd></dl>
<div class="fragment"><pre class="fragment">ISR(SIG_OVERFLOW0) {
        ...
    <a class="code" href="os__appl_a_p_i_8h.html#a1d7bc0554f6b515785211dd2c3f2d3d9">os_tick</a>();  
}
</pre></div> 
</div>
</div>
<a class="anchor" id="aaecd95706696b8ff18d5ef74d139d750"></a><!-- doxytag: member="os_applAPI.h::sem_bin_create" ref="aaecd95706696b8ff18d5ef74d139d750" args="(uint8_t initial)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Sem_t <a class="el" href="os__appl_a_p_i_8h.html#aaecd95706696b8ff18d5ef74d139d750">sem_bin_create</a> </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>initial</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Creates and initializes a new binary semaphore.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">initial</td><td>value of the semaphore</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Returns the created semaphore.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 A semaphore is created by declaring a variable of type Sem_t and then assigning the sem_create(value) return value to that variable.</dd></dl>
<div class="fragment"><pre class="fragment">       Sem_t mySem;
       mySem = <a class="code" href="os__appl_a_p_i_8h.html#aaecd95706696b8ff18d5ef74d139d750">sem_bin_create</a>(0);
</pre></div> 
</div>
</div>
<a class="anchor" id="a9cfb5b3cc72fdaed17009a0cae7fd725"></a><!-- doxytag: member="os_applAPI.h::sem_counting_create" ref="a9cfb5b3cc72fdaed17009a0cae7fd725" args="(uint8_t max, uint8_t initial)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">Sem_t <a class="el" href="os__appl_a_p_i_8h.html#a9cfb5b3cc72fdaed17009a0cae7fd725">sem_counting_create</a> </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>max</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>initial</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Creates and initializes a new counting semaphore.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">max</td><td>value of the semaphore </td></tr>
    <tr><td class="paramname">initial</td><td>value of the semaphore</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Returns the created semaphore.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 A semaphore is created by declaring a variable of type Sem_t and then assigning the sem_create(max, 0) return value to that variable.</dd></dl>
<div class="fragment"><pre class="fragment">       Sem_t mySem;
       mySem = <a class="code" href="os__appl_a_p_i_8h.html#a9cfb5b3cc72fdaed17009a0cae7fd725">sem_counting_create</a>(5,0);
</pre></div> 
</div>
</div>
<a class="anchor" id="adb53dc7146d0e27f8ac2675f62dd6124"></a><!-- doxytag: member="os_applAPI.h::task_create" ref="adb53dc7146d0e27f8ac2675f62dd6124" args="(taskproctype taskproc, uint8_t prio, Msg_t *msgPool, uint8_t poolSize, uint16_t msgSize)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t <a class="el" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a> </td>
          <td>(</td>
          <td class="paramtype">taskproctype&#160;</td>
          <td class="paramname"><em>taskproc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>prio</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Msg_t *&#160;</td>
          <td class="paramname"><em>msgPool</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>poolSize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>msgSize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Creates a task scheduled by the os. The task is put in the ready state.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">taskproc</td><td>Function pointer to the task procedure. </td></tr>
    <tr><td class="paramname">prio</td><td>Task priority on a scale 0-255 where 0 is the highest priority. </td></tr>
    <tr><td class="paramname">msgPool</td><td>Pointer to the message pool, containing messages. Ignored if poolSize is 0. </td></tr>
    <tr><td class="paramname">poolSize</td><td>Size of the message pool. Set to 0 if no message pool needed for the task </td></tr>
    <tr><td class="paramname">msgSize</td><td>Size of the message type held in the message queue </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Task id of the created task.</dd></dl>
<dl class="remark"><dt><b>Remarks:</b></dt><dd><b>Usage:</b> <br/>
 Should be called early in system setup, before starting the task execution. Only one task per priority level is allowed.</dd></dl>
<div class="fragment"><pre class="fragment"><span class="keyword">static</span> uint8_t taskId;
<span class="keyword">static</span> Msg_t msgpool_1[ POOL_SIZE ];

<span class="keywordtype">int</span> main(<span class="keywordtype">void</span>) {
        system_init();
        <a class="code" href="os__appl_a_p_i_8h.html#a6cc2e63d83267ff5059bf0a76b302a09">os_init</a>();
        taskId = <a class="code" href="os__appl_a_p_i_8h.html#adb53dc7146d0e27f8ac2675f62dd6124">task_create</a>( myTaskProc, 1, msgpool_1, POOL_SIZE, <span class="keyword">sizeof</span>(Msg_t) );
        ...
}
</pre></div> 
</div>
</div>
<a class="anchor" id="ab9e114be01c136878fc271be2a9c45cf"></a><!-- doxytag: member="os_applAPI.h::task_id_get" ref="ab9e114be01c136878fc271be2a9c45cf" args="(taskproctype taskproc)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t <a class="el" href="os__appl_a_p_i_8h.html#ab9e114be01c136878fc271be2a9c45cf">task_id_get</a> </td>
          <td>(</td>
          <td class="paramtype">taskproctype&#160;</td>
          <td class="paramname"><em>taskproc</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Gets the task id of the task associated with the specified task procedure</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">taskproc</td><td>Function pointer to the task procedure.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>TaskId of the task</dd></dl>
<div class="fragment"><pre class="fragment"><span class="keyword">static</span> <span class="keywordtype">void</span> waitingTask(<span class="keywordtype">void</span>)
{
    <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>()

    <a class="code" href="os__appl_a_p_i_8h.html#a576b2326d068ab852846ee612c7b954c">event_wait</a>( event );

    if ( event_signaling_taskId_get( event ) == task_id_get( signalingTask1 ) ) {
        ...
    }

        <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();

}


<span class="keyword">static</span> <span class="keywordtype">void</span> signalingTask1(<span class="keywordtype">void</span>)
{
        <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();    
        
        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 900 );
       
    <a class="code" href="os__appl_a_p_i_8h.html#a194e9ed0f676ffc46a782754b58a0475">event_signal</a>(event);

        <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();

}
</pre></div> 
</div>
</div>
<a class="anchor" id="a36df952f331631590dc3a982e0e8a2d4"></a><!-- doxytag: member="os_applAPI.h::task_kill" ref="a36df952f331631590dc3a982e0e8a2d4" args="(taskproctype taskproc)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="os__appl_a_p_i_8h.html#a36df952f331631590dc3a982e0e8a2d4">task_kill</a> </td>
          <td>(</td>
          <td class="paramtype">taskproctype&#160;</td>
          <td class="paramname"><em>taskproc</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Puts the task associated with the specified task procedure in the killed state. A killed task, cannot be resumed.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">taskproc</td><td>Function pointer to the task procedure.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>None</dd></dl>
<div class="fragment"><pre class="fragment"><span class="keyword">static</span> <span class="keywordtype">void</span> waitingTask(<span class="keywordtype">void</span>)
{
    <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();

    <a class="code" href="os__appl_a_p_i_8h.html#a576b2326d068ab852846ee612c7b954c">event_wait</a>( event );

    <span class="keywordflow">if</span> ( <a class="code" href="os__appl_a_p_i_8h.html#ae28468ad6bb58df9d34ebd5bd3daa548">event_signaling_taskId_get</a>( event ) == <a class="code" href="os__appl_a_p_i_8h.html#ab9e114be01c136878fc271be2a9c45cf">task_id_get</a>( signalingTask1 ) ) {
        <a class="code" href="os__appl_a_p_i_8h.html#a36df952f331631590dc3a982e0e8a2d4">task_kill</a>( signalingTask1 );
    }

        <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();

}


<span class="keyword">static</span> <span class="keywordtype">void</span> signalingTask1(<span class="keywordtype">void</span>)
{
        <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();    
        
        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 900 );
       
    <a class="code" href="os__appl_a_p_i_8h.html#a194e9ed0f676ffc46a782754b58a0475">event_signal</a>(event);

        <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();

}
</pre></div> 
</div>
</div>
<a class="anchor" id="a5587eb98c16ed4dd2adaa8ae2f3bb1e1"></a><!-- doxytag: member="os_applAPI.h::task_state_get" ref="a5587eb98c16ed4dd2adaa8ae2f3bb1e1" args="(taskproctype taskproc)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">TaskState_t <a class="el" href="os__appl_a_p_i_8h.html#a5587eb98c16ed4dd2adaa8ae2f3bb1e1">task_state_get</a> </td>
          <td>(</td>
          <td class="paramtype">taskproctype&#160;</td>
          <td class="paramname"><em>taskproc</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Gets the current state of the task associated with the specified procedure</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">taskproc</td><td>Function pointer to the task procedure.</td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>State of the task</dd></dl>
<div class="fragment"><pre class="fragment"><span class="keyword">static</span> <span class="keywordtype">void</span> led_task500(<span class="keywordtype">void</span>)
{
    <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();        
    
    <span class="keywordflow">for</span> (;;) {
        LED_TOGGLE(0);
        
        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 500 );
    }

    <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();
}


<span class="keyword">static</span> <span class="keywordtype">void</span> led_task1000(<span class="keywordtype">void</span>)
{
    <a class="code" href="os__appl_a_p_i_8h.html#ac19d6a48c1cb673360ae220aaf2a9d53">task_open</a>();        

    <span class="keywordflow">for</span> (;;) {
        <a class="code" href="os__appl_a_p_i_8h.html#ab14d890b777d3b2a9e4c83a3ec15dd31">sem_wait</a>( buttonSem );

        <span class="keywordflow">if</span> ( buttonPressed ) {
            <span class="keywordflow">if</span> ( SUSPENDED &lt; <a class="code" href="os__appl_a_p_i_8h.html#a5587eb98c16ed4dd2adaa8ae2f3bb1e1">task_state_get</a>( led_task500 ) ) {
                <a class="code" href="os__appl_a_p_i_8h.html#a7d1f6736c118f92f06a5d9218e0ba977">task_suspend</a>( led_task500 );
            }

        }
        <span class="keywordflow">else</span> {
            <span class="keywordflow">if</span> ( SUSPENDED == <a class="code" href="os__appl_a_p_i_8h.html#a5587eb98c16ed4dd2adaa8ae2f3bb1e1">task_state_get</a>( led_task500 ) ) {
                <a class="code" href="os__appl_a_p_i_8h.html#a6de09b7f20e384d58bbf330c19447a79">task_resume</a>( led_task500 );
            }
        }

        <a class="code" href="os__appl_a_p_i_8h.html#aa5011c236fb03784283e6476e9ae5adb">sem_signal</a>( buttonSem );

        LED_TOGGLE(1);


        <a class="code" href="os__appl_a_p_i_8h.html#ad8232a672a6d4f3a4532bea410a0b1ef">task_wait</a>( 900 );
    }

    <a class="code" href="os__appl_a_p_i_8h.html#a7912af19af4a033fd9caf27879614945">task_close</a>();

}
</pre></div> 
</div>
</div>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="os__appl_a_p_i_8h.html">os_applAPI.h</a>      </li>

    <li class="footer">Generated on Thu Dec 22 2011 21:14:42 for cocoOS by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6 </li>
   </ul>
 </div>


</body>
</html>
